<?php

    class Sitem extends CI_Model{

        function __construct(){
            parent::__construct();
        }

        function read($page='',$sub='',$upsub=''){

            switch ($page){
                case 'home': $page= 'novosti'; break;
            }

            $this->db->order_by("datetime", "desc"); 
            $row = $this->db->get_where('text',array('page'=>$page,'lang'=>$this->lang_ses->getLang()))->result_array();

            /*
            * If no data
            * create new object with message
            */ 

            /*if(count($row)==0){   

            $instance = new newRow($this->lang->line('nodata'));
            $row = $instance;     

            }*/

            return $row; 
        }

        function readAll($page){
            $row = $this->db->get_where('text',array('page'=>$page,'lang'=>$this->lang_ses->getLang()))->result_array();
            return $row;
        }

        function getTitle($page = 'home', $sub = '', $upsub = ''){

            switch($this->lang_ses->getLang()){ 

                case 'me':
                switch($page){
                    case 'home': return 'Dobrodošli'; break;
                    case 'onama': return 'O nama'; break;
                    case 'usloviputovanja': return 'Opšti uslovi putovanja'; break;
                    case 'posao': return 'Posao'; break;
                    case 'faq': return 'FAQ'; break;
                    case 'redplovidbe': return 'Red plovidbe'; break;
                    case 'cjenovnik': return 'Cjenovnik'; break;
                    case 'spedicija': return 'Špedicija'; break;
                    case 'kontakt': return 'Kontakt'; break;
                    case 'promocije': return 'Promocije'; break;
                    case 'novosti': return 'Novosti'; break;

                }
                break;
                
                case 'en':
                switch($page){
                    case 'home': return 'Welcome'; break;
                    case 'onama': return 'About Us'; break;
                    case 'usloviputovanja': return 'General conditions of travel'; break;
                    case 'posao': return 'Job application'; break;
                    case 'faq': return 'FAQ'; break;
                    case 'redplovidbe': return 'Timetable'; break;
                    case 'cjenovnik': return 'Tariffs'; break;
                    case 'spedicija': return 'Forwarding'; break;
                    case 'kontakt': return 'Contact'; break;
                    case 'promocije': return 'Promotions'; break;
                    case 'novosti': return 'News and announcement'; break;

                }
                break;
                
                case 'it':
                switch($page){
                    case 'home': return 'Home'; break;
                    case 'onama': return 'Chi siamo'; break;
                    case 'usloviputovanja': return 'Condizioni generali'; break;
                    case 'posao': return 'Job application'; break;
                    case 'faq': return 'FAQ'; break;
                    case 'redplovidbe': return 'Orario'; break;
                    case 'cjenovnik': return 'Tariffe'; break;
                    case 'spedicija': return 'Spedizioni'; break;
                    case 'kontakt': return 'Contatti'; break;
                    case 'promocije': return 'Promotions'; break;
                    case 'novosti': return 'News and announcement'; break;

                }
                break;
                
                case 'al':
                switch($page){
                    case 'home': return 'Welcome'; break;
                    case 'onama': return 'Rretsh nesh'; break;
                    case 'usloviputovanja': return 'General conditions of travel'; break;
                    case 'posao': return 'Job application'; break;
                    case 'faq': return 'FAQ'; break;
                    case 'redplovidbe': return 'Rendi  i  lundrimit'; break;
                    case 'cjenovnik': return 'Tarifat'; break;
                    case 'spedicija': return 'Forwarding'; break;
                    case 'kontakt': return 'Contact'; break;
                    case 'promocije': return 'Promotions'; break;
                    case 'novosti': return 'News and announcement'; break;

                }
                break;
                
                
            }

        }

    }

    class newRow
    {
        public $title = '';
        public $text = '';

        function __construct($txt){
            $this->title = $txt;
        }
    }



?>
